package cn.topevery.garden.dal.dao.impl;

import cn.topevery.garden.dal.dao.ProjectProgressDao;
import cn.topevery.garden.entity.po.ProjectProgress;
import cn.topevery.garden.entity.query.ProjectProgressQuery;
import cn.topevery.garden.framework.base.BaseDaoImpl;
import hw.topevery.framework.db.entity.DataPager;
import hw.topevery.framework.db.entity.SqlQueryMate;
import hw.topevery.framework.db.enums.ScriptConditionEnum;
import hw.topevery.framework.entity.DbCsp;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 
 *
 * @author code-generate
 * @date 2021-09-01
 */
@Repository
public class ProjectProgressDaoImpl extends BaseDaoImpl<ProjectProgress> implements ProjectProgressDao {
    @Override
    public <P extends DbCsp> List<ProjectProgress> getSearch(P para) {
        return null;
    }

    

    @Override
    public DataPager<ProjectProgress> listPage(ProjectProgressQuery query) {
        String table = "t_project_progress tpp";

        String columns = "tpp.*";

        int pageIndex = query.pageIndex - 1;
        int pageSize = query.pageSize;

        SqlQueryMate sqlQueryMate = new SqlQueryMate(table).setColumns(columns).setOrderBy("tpp.c_id desc");
        sqlQueryMate
                .where(true, "tpp.c_db_status", ScriptConditionEnum.Eq, 0)
        ;

        return getDataPager(sqlQueryMate, pageSize, pageIndex, ProjectProgress.class);
    }

    /**
     * 描述 获取列表
     *
     * @param pid the pid
     * @return the list by pid
     * @author wenzhao.lin
     * @created 2021 -08-26 09:09:27
     */
    @Override
    public List<ProjectProgress> getListByPid(Integer pid) {
        String table = "t_project_progress tpc";

        String columns = "tpc.*";

        SqlQueryMate sqlQueryMate = new SqlQueryMate(table).setColumns(columns).setOrderBy("tpc.c_db_create_date asc");
        sqlQueryMate
                .where(true, "tpc.c_db_status", ScriptConditionEnum.Eq, 0)
                .where(true, "tpc.c_project_id", ScriptConditionEnum.Eq, pid)
        ;
        return selectList(sqlQueryMate, ProjectProgress.class);
    }
}
